﻿@model Zor_Web.Models.Base.V_Acceptance
@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>受理单管理</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
    <!-- 表单验证 -->
    <script src="~/Content/Scripts/JValidator.js"></script>
    <!-- 税收算法 -->
    <script src="~/Content/Scripts/RatMoney.js"></script>
</head>
<body class="gray-bg">

    <div class="layui-tab layui-tab-brief main-tab-container ">
        <div class="col-sm-12 ct-padding">
            <div class="col-sm-9 ct-padding">
                <button id="btnUpdate" class="layui-btn layui-btn-warm  layui-btn-small"><span class="glyphicon glyphicon-pencil"></span> 编辑</button>
                <button id="btnPush" class="layui-btn layui-btn-normal layui-btn-small">  <span class="glyphicon glyphicon-pencil"></span>推送 </button>
                <button id="btnDelete" class="layui-btn layui-btn-danger  layui-btn-small"><span class="glyphicon glyphicon-trash"></span> 删除</button>
                <button id="btnSearch" class="layui-btn layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <button id="btnMessage" class="layui-btn layui-btn-orchid  layui-btn-small"><span class="glyphicon glyphicon-list-alt"></span> 详情</button>              
                <button id="btnReplace" class="layui-btn layui-btn-blue layui-btn-small"><span class="glyphicon glyphicon-refresh"></span> 刷新</button>
            </div>
        </div>
        <div class="layui-tab-content" style="overflow-x: scroll; white-space: nowrap;">
            <table class="layui-table" lay-skin="line">
                <thead>
                    <tr>
                        <th hidden></th>
                        <th></th>
                        <th hidden>缴税起始日期</th>
                        <th hidden>缴税终止日期</th>
                        <th hidden>租赁开始日期</th>
                        <th hidden>租赁终止日期</th>
                        <th>受理单号</th>
                        <th>身份证号</th>
                        <th>纳税人</th>
                        <th>受理状态</th>
                        <th>联系方式</th>
                        <th>税号</th>
                        <th>付款人</th>
                        <th>产权</th>
                        <th>房屋属性</th>
                        <th>面积</th>
                        <th>租金(元/月)</th>
                        <th>地址</th>
                    </tr>
                </thead>
                <tbody id="accordion">
                    @foreach (var item in Model.PageData)
                    {
                        <tr>
                            <td hidden>@item.Acceptance_Id</td>
                            <td><input type="radio" name="chk" id="@item.Acceptance_Id" value="@item.Acceptance_Id" /></td>
                            <td hidden>@TimeHelper.TimeStampToDateTime(item.Acceptance_TaxStartTime.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            <td hidden>@TimeHelper.TimeStampToDateTime(item.Acceptance_TaxEndTime.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            <td hidden>@TimeHelper.TimeStampToDateTime(item.Lease_StartTime, TimeHelper.ToTimeType.link_ymd)</td>
                            <td hidden>@TimeHelper.TimeStampToDateTime(item.Lease_EndTime, TimeHelper.ToTimeType.link_ymd)</td>
                            <td>@item.Acceptance_TicketNumber</td><!-- 6 -->
                            <td>@item.NatPer_IDNumber</td><!-- 7 -->
                            <td>@item.NatPer_Name</td><!-- 8 -->
                            @if (@item.State == "被退回")
                            {
                                <td style="color:red">@item.State</td><!-- 9 -->
                            }
                            else
                            {
                                <td>@item.State</td><!-- 9 -->
                            }
                            <td>@item.NatPer_Phone</td><!-- 10 -->
                            <td>@item.Acceptance_TaxNumber</td><!-- 11 -->
                            <td>@item.Tenant_Name</td><!-- 12 -->
                            <td>@item.Csqx</td><!-- 13 -->
                            <td>@item.AHA</td><!-- 14 -->
                            <td>@item.Hs_Proportion</td><!-- 15 -->
                            <td>@(item.LeaseRent*0.01)</td><!-- 16 -->
                            <td>@item.Acceptance_Address</td><!-- 17 -->
                            <td hidden>@item.Lease_Id</td><!-- 18 -->
                            <td hidden>@item.Acceptance_State</td><!-- 19 -->
                            <td hidden>@item.ReviewUser</td><!-- 20 -->
                            <td hidden>@(item.ReviewRent*0.01)</td><!-- 21 -->
                            @if (item.Review_Date != 0)
                            {
                                <td hidden>@TimeHelper.TimeStampToDateTime(item.Review_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            }
                            else
                            {
                                <td hidden></td>
                            }
                            <td hidden>@item.Review_Comment</td><!-- 23 -->
                            <td hidden>@(item.EReviewRent*0.01)</td><!-- 24 -->
                            <td hidden>@item.EvaluateUser</td><!-- 25 -->
                            @if (item.Evaluate_Date != 0)
                            {
                                <td hidden>@TimeHelper.TimeStampToDateTime(item.Evaluate_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            }
                            else
                            {
                                <td hidden></td>
                            }
                            <td hidden>@item.Evaluate_Comment</td><!-- 27 -->
                            <td hidden>@item.ExamineUser</td><!-- 28 -->
                            @if (item.Examine_Date != 0)
                            {
                                <td hidden>@TimeHelper.TimeStampToDateTime(item.Examine_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            }
                            else
                            {
                                <td hidden></td>
                            }
                            <td hidden>@item.Examine_Comment</td><!-- 30 -->
                            <td hidden>@(item.Pt_ActualTax*0.01)</td><!-- 31 -->
                            <td hidden>@item.PtUser</td><!-- 32 -->
                            @if (item.Pt_Date != 0)
                            {
                                <td hidden>@TimeHelper.TimeStampToDateTime(item.Pt_Date.ToString(), TimeHelper.ToTimeType.link_ymd)</td>
                            }
                            else
                            {
                                <td hidden></td>
                            }
                        </tr>
                    }
                </tbody>



            </table>
        </div>
        <div class="col-sm-12">
            <div class="col-sm-10">
                @Html.Pager(Model.PageData, new PagerOptions { PageIndexParameterName = "index", ContainerTagName = "ul", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", PagerItemsSeperator = "", CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a href=\"#\">{0}</a></li>", PagerItemWrapperFormatString = "<li>{0}</li>" }, new { id = "bootstrappager", @class = "pagination" })
            </div>
            <div class="col-sm-2 to-righjt">
                共 @Model.PageData.TotalItemCount 条记录，页 @Model.PageData.CurrentPageIndex/@Model.PageData.TotalPageCount
            </div>
        </div>
    </div>
    <!-- 模态 -->
    <div id="myModal" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form class="form-horizontal m-t">
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">ID：</label>
                    <div class="col-sm-9">
                        <input id="Acceptance_Id" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">赁ID：</label>
                    <div class="col-sm-9">
                        <input id="Lease_Id" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">受理单号：</label>
                    <div class="col-sm-9">
                        <input id="Acceptance_TicketNumber" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item" hidden>
                    <label class="col-sm-3 layui-form-label">受理单状态：</label>
                    <div class="col-sm-9">
                        <input id="Acceptance_State" type="text" class="form-control">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">姓名：</label>
                    <div class="col-sm-4">
                        <input readonly id="NatPer_Name" type="text" class="form-control" placeholder="请输入角色名称" autofocus="autofocus">
                    </div>
                    <label class="col-sm-2 layui-form-label">身份证号：</label>
                    <div class="col-sm-4">
                        <input readonly id="NatPer_IDNumber" type="text" class="form-control" placeholder="请输入楼宇名称" autofocus="autofocus">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">联系电话：</label>
                    <div class="col-sm-4">
                        <input readonly id="NatPer_Phone" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                    <label class="col-sm-2 layui-form-label">面积：</label>
                    <div class="col-sm-4">
                        <input readonly id="Hs_Proportion" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>                    
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">租赁开始日期：</label>
                    <div class="col-sm-4">
                        <input readonly id="Lease_StartTime" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                    <label class="col-sm-2 layui-form-label">租赁截止日期：</label>
                    <div class="col-sm-4">
                        <input readonly id="Lease_EndTime" type="text" class="form-control" placeholder="..." autofocus="autofocus" />
                    </div>
                </div>
                <div class="layui-form-item">

                    <label class="col-sm-2 layui-form-label">税起日期：</label>
                    <div class="col-sm-4">
                        <input id="Acceptance_TaxStartTime" type="text" class="form-control laydate-icon layer-date" placeholder="请选择税收起始时间" autofocus="autofocus" datacol="yes" err="税收起始时间" checkexpession="NotNull" />
                    </div>
                    <label class="col-sm-2 layui-form-label">税止日期：</label>
                    <div class="col-sm-4">
                        <input id="Acceptance_TaxEndTime" type="text" class="form-control laydate-icon layer-date" placeholder="请选择税收结束时间" autofocus="autofocus" datacol="yes" err="税收结束时间" checkexpession="NotNull" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">租金(元)：</label>
                    <div class="col-sm-4">
                        <input readonly id="Lease_Rent" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                    <label class="col-sm-2 layui-form-label">税号：</label>
                    <div class="col-sm-4">
                        <input id="Acceptance_TaxNumber" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">付款人/单位：</label>
                    <div class="col-sm-4">
                        <input readonly id="Tenant_Name" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                    <label class="col-sm-2 layui-form-label">地址：</label>
                    <div class="col-sm-4">
                        <input id="Acceptance_Address" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>                    
                </div>
                <div class="layui-form-item" hidden>                   
                    <label class="col-sm-2 layui-form-label">房屋属性：</label>
                    <div class="col-sm-4">
                        <input id="Hs_attribute" type="text" class="form-control" placeholder="..." autofocus="autofocus">
                    </div>
                </div>
            </form>
        </div> 
        <div class="form-group">
            <div class="col-sm-12 ">
                <button id="btnSure" class="btn btn-info pull-right">
                    <i class="fa fa-check"></i>提交
                </button>
            </div>
        </div>
    </div>


    @using (Html.BeginForm("Zor_Acceptance", "Base", new RouteValueDictionary { { "Model", Model } }, FormMethod.Get))
    {
    <!-- 查询模态框 -->
        <div id="myModalSearch" hidden data-backdrop="static">
            <div id="divselectfrom" class="layui-tab-content">
                <form class="form-horizontal m-t">
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">租赁开始日期：</label>
                        <div class="col-sm-9">
                            <input id="Search_StartTime" class="laydate-icon form-control layer-date" name="Lease_StartTime" value="@Model.Lease_StartTime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">租赁截止日期：</label>
                        <div class="col-sm-9">
                            <input id="Search_EndTime" class="laydate-icon form-control layer-date" name="Lease_EndTime" value="@Model.Lease_EndTime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">受理单号：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="Acceptance_TicketNumber" value="@Model.Acceptance_TicketNumber">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">受理单状态：</label>
                        <div class="col-sm-9">
                            <select name="State" class="form-control">
                                <option value="@Model.State">全部</option>
                                <option value="@Model.State">已保存</option>
                                <option value="@Model.State">已提交</option>
                                <option value="@Model.State">被退回</option>
                                <option value="@Model.State">已评议</option>
                                <option value="@Model.State">已评定</option>
                                <option value="@Model.State">已审核</option>
                                <option value="@Model.State">已缴税</option>
                                <option value="@Model.State">已开票</option>
                                <option value="@Model.State">已销号</option>
                                <option value="@Model.State">已汇总</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">税号：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="Acceptance_TaxNumber" value="@Model.Acceptance_TaxNumber">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="col-sm-3 layui-form-label">付款人：</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="Tenant_Name" value="@Model.Tenant_Name">
                        </div>
                    </div>

                </form>
                <div class="box-footer">
                    <button type="submit" class="btn btn-info pull-right">
                        <i class="fa fa-search"></i>查询
                    </button>
                </div>
            </div>
        </div>
    }

    <!-- 详情模态 -->
    <div id="myModalDetails" hidden data-backdrop="static">
        <div id="divfrom" class="layui-tab-content">
            <form method="get" class="form-horizontal">
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">地址：</label>
                    <div class="col-sm-10 layui-input" id="Acceptance_AddressD"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">业主姓名：</label>
                    <div class="col-sm-2 layui-input" id="NatPer_NameD"></div>
                    <label class="col-sm-2 layui-form-label">业主联系电话：</label>
                    <div class="col-sm-2 layui-input" id="NatPer_PhoneD"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">房屋面积：</label>
                    <div class="col-sm-2 layui-input" id="Hs_ProportionD"></div>
                    <label class="col-sm-2 layui-form-label">初始租金(元)：</label>
                    <div class="col-sm-2 layui-input" id="LeaseRentD"></div>
                    <label class="col-sm-2 layui-form-label">当前状态：</label>
                    <div class="col-sm-2 layui-input" id="StateD"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">身份证号：</label>
                    <div class="col-sm-2 layui-input" id="NatPer_IDNumberD"></div>
                    <label class="col-sm-2 layui-form-label">起租时间：</label>
                    <div class="col-sm-2 layui-input" id="Lease_StartTimeD"></div>
                    <label class="col-sm-2 layui-form-label">截止时间：</label>
                    <div class="col-sm-2 layui-input" id="Lease_EndTimeD"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">评议租金(元)：</label>
                    <div class="col-sm-2 layui-input" id="ReviewRent"></div>
                    <label class="col-sm-2 layui-form-label">评议人：</label>
                    <div class="col-sm-2 layui-input" id="ReviewUser"></div>
                    <label class="col-sm-2 layui-form-label">评议时间：</label>
                    <div class="col-sm-2 layui-input" id="Review_Date"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">评议意见：</label>
                    <div class="col-sm-10 layui-input" id="Review_Comment"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">评定租金(元)：</label>
                    <div class="col-sm-2 layui-input" id="EReviewRent"></div>
                    <label class="col-sm-2 layui-form-label">评定人：</label>
                    <div class="col-sm-2 layui-input" id="EvaluateUser"></div>
                    <label class="col-sm-2 layui-form-label">评定时间：</label>
                    <div class="col-sm-2 layui-input" id="Evaluate_Date"></div>
                </div>
                <div class="layui-form-item">

                    <label class="col-sm-2 layui-form-label">评定意见：</label>
                    <div class="col-sm-10 layui-input" id="Evaluate_Comment"></div>
                </div>
                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">审核人：</label>
                    <div class="col-sm-2 layui-input" id="ExamineUser"></div>
                    <label class="col-sm-2 layui-form-label">审核时间：</label>
                    <div class="col-sm-2 layui-input" id="Examine_Date"></div>                  
                </div>
                <div class="layui-form-item">

                    <label class="col-sm-2 layui-form-label">审核意见：</label>
                    <div class="col-sm-10 layui-input" id="Examine_Comment"></div>
                </div>

                <div class="layui-form-item">
                    <label class="col-sm-2 layui-form-label">应交税款(元)：</label>
                    <div class="col-sm-2 layui-input" id="Pt_ActualTax"></div>
                    <label class="col-sm-2 layui-form-label">操作人：</label>
                    <div class="col-sm-2 layui-input" id="PtUser"></div>
                    <label class="col-sm-2 layui-form-label">操作时间：</label>
                    <div class="col-sm-2 layui-input" id="Pt_Date"></div>
                </div>
            </form>

        </div>
    </div>
</body>
</html>
<script>


    /**
    *   日期选择器--受理单
    */
    laydate.skin('molv');         //日历皮肤
    var startA = {                   //开始时间选择
        elem: "#Acceptance_TaxStartTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) {
            end.min = datas;
            end.start = datas
        }
    };
    var endA = {                     //结束时间选择
        elem: "#Acceptance_TaxEndTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) { start.max = datas }
    };
    laydate(startA);
    laydate(endA);

    /**
   *   日期选择器---查询租赁日期
   */
    laydate.skin('molv');         //日历皮肤
    var startS = {                   //开始时间选择
        elem: "#Search_StartTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) {
            end.min = datas;
            end.start = datas
        }
    };
    var endS = {                     //结束时间选择
        elem: "#Search_EndTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) {
            start.max = datas
        }
    };
    laydate(startS);
    laydate(endS);


    ///详情
    $(function () {
        /*刷新*/

        $("#btnReplace").click(function () {
            Replace();
        });

        $("#btnMessage").click(function () {
            var checkId = CheckboxValueIDs();
            if (checkId.length == 0) {
                layer.msg("请选择要查看的租赁信息！");
                return;
            }
            if (checkId.length > 1) {
                layer.msg("仅可选择一行信息查看！");
                return;
            }            
            LayerOpen('1000px', '580px', '受理单详情', $('#myModalDetails'));
            $("#Acceptance_AddressD").html(getTableCell(17));
            $("#NatPer_NameD").html(getTableCell(8));
            $("#NatPer_PhoneD").html(getTableCell(10));
            $("#Hs_ProportionD").html(getTableCell(15));
            $("#LeaseRentD").html(getTableCell(16));
            $("#StateD").html(getTableCell(9));
            $("#NatPer_IDNumberD").html(getTableCell(7));
            $("#Lease_StartTimeD").html(getTableCell(4));
            $("#Lease_EndTimeD").html(getTableCell(5));
            $("#ReviewRent").html(getTableCell(21));
            $("#ReviewUser").html(getTableCell(20));
            $("#Review_Date").html(getTableCell(22));
            $("#Review_Comment").html(getTableCell(23));
            $("#EReviewRent").html(getTableCell(24));
            $("#EvaluateUser").html(getTableCell(25));
            $("#Evaluate_Date").html(getTableCell(26));
            $("#Evaluate_Comment").html(getTableCell(27));
            $("#ExamineUser").html(getTableCell(28));
            $("#Examine_Date").html(getTableCell(29));
            $("#Examine_Comment").html(getTableCell(30));
            $("#Pt_ActualTax").html(getTableCell(31));
            $("#PtUser").html(getTableCell(32));
            $("#Pt_Date").html(getTableCell(33));
        })
    })

    /**
   * 编辑受理单信息
   */

    $(function () {
        $("#btnUpdate").click(function () {

            var checkId = CheckboxValueIDs();           //获取选中行的受理单信息ID
            var NatPer_IDNumber = getTableCell(7);          //获取选中行的业主身份证
            var Acceptance_TaxStartTime = getTableCell(2);          //获取选中行的税起日期
            var Acceptance_TaxEndTime = getTableCell(3);          //获取选中行的税止日期
            var Acceptance_TaxNumber = getTableCell(11);          //获取选中行的税号
            var Acceptance_Address = getTableCell(17);          //获取选中行的地址
            var NatPer_Name = getTableCell(8);    //获取选中行的业主姓名
            var NatPer_Phone = getTableCell(10);   //获取选中行的业主电话
            var Hs_Proportion = getTableCell(15);        //获取选中行的房屋房屋面积
            var Lease_StartTime = getTableCell(4);      //获取选中行的租赁开始日期
            var Lease_EndTime = getTableCell(5);       //获取选中行的租赁截止日期
            var Lease_Rent = getTableCell(16);           //获取选中行的租金
            var Tenant_Name = getTableCell(12);          //获取选中行的租户名称
            var Lease_Id = getTableCell(18);
            var Hs_attribute = getTableCell(14);
            if (checkId.length == 0) {
                layer.msg("请选择要编辑的受理单信息！");
                return;
            }
            if (checkId.length > 1) {
                layer.msg("仅可选择一条受理单信息进行编辑！");
                return;
            }
            $("#Acceptance_Id").val(checkId[0]);
            $("#Acceptance_TaxStartTime").val(Acceptance_TaxStartTime);
            $("#Acceptance_TaxEndTime").val(Acceptance_TaxEndTime);
            $("#Acceptance_TaxNumber").val(Acceptance_TaxNumber);
            $("#Acceptance_Address").val(Acceptance_Address);
            $("#NatPer_IDNumber").val(NatPer_IDNumber);
            $("#NatPer_Name").val(NatPer_Name);
            $("#NatPer_Phone").val(NatPer_Phone);
            $("#Hs_Proportion").val(Hs_Proportion);
            $("#Lease_Rent").val(Lease_Rent);
            $("#Lease_StartTime").val(Lease_StartTime);
            $("#Lease_EndTime").val(Lease_EndTime);
            $("#Tenant_Name").val(Tenant_Name); 
            $("#Lease_Id").val(Lease_Id);
            $("#Acceptance_TicketNumber").val(getTableCell(6));
            $("#Acceptance_State").val(getTableCell(19)); 
            $("#Hs_attribute").val(Hs_attribute);
            LayerOpen('800px', '400px', '受理单修改', $('#myModal'));
        })
    })

    /**
    * 推送
    */
    $(function () {
        $("#btnPush").click(function () {
            var checkId = CheckboxValueIDs();           //获取选中行的受理单信息ID          
            var acceptancestate = getTableCell(19);//受理单状态   
            if (checkId.length == 0) {
                layer.msg("请选择要推送的受理单！"); //未选中任何行
                return;
            }
            if (checkId.length > 1) {
                layer.msg("请选择一条记录推送！");
                return;
            }
            if (acceptancestate != 0 && acceptancestate != 2) {
                layer.msg("不能重复推送！"); //未选中任何行
                return;
            }       
            else {
                //var PropertyTax = parseInt(fcRat * 100); //计算后的个税              
                //var PersonalTax = parseInt(GrRat * 100); //计算后房产税
                //var Acceptance_Tax = (parseInt(GrRat) + parseInt(fcRat)) * 100; //计算后的税金
                //var Acceptance_TotalTax = parseInt(totalRent * 100);//计税总额  

                layer.confirm("确定要推送吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                    ZorPostSimpleData("/Base/AccPush", JSON.stringify({ 'acceptanceid': checkId[0], 'acceptancestate': acceptancestate }), function (data) { //获取数据(带参数)
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    })
                })
            }
        });
    })
    /**
    * 保存受理单信息
    */
    $(function () {
        $("#btnSure").click(function () {
            var Acceptance_State = getTableCell(19); //获取受理单状态         
            if (!CheckDataValid('.form-horizontal')) {
                return false;
            }
            if (!checkEndTime($("#Lease_StartTime").val(), $("#Acceptance_TaxStartTime").val())) {
                layer.msg("税收起始时间必须晚于租赁起始时间！");
                return;
            }
            if (Acceptance_State !=2 && Acceptance_State !=0) {
                layer.msg("当前受理单已提交上级，不能修改！");
                return;
            }           
                if (Acceptance_State == 2 || Acceptance_State == 0) {                         
                var JsData = GetWebControls(divfrom);
                var bgDate = $("#Acceptance_TaxStartTime").val();
                var endDate = $("#Acceptance_TaxEndTime").val();
                //修改税收起止日期后，修改受理单中的税金和计税总额
             
                var rentMoney = $("#Lease_Rent").val();               
                var type = $("#Hs_attribute").val();              
                if (type == "住宅")
                {
                    type = "1";
                }
                else
                {
                    type = "2";
                }                             
                getRatMoney(bgDate, endDate, rentMoney, type);
                var PropertyTax = fcRat.toFixed(2) * 100; //计算后的个税              
                var PersonalTax = GrRat.toFixed(2) * 100; //计算后房产税
                var Acceptance_Tax = jszje.toFixed(2) * 100;//税金 = 房产税+个人所得税
                //var Acceptance_Tax = (parseInt(GrRat) + parseInt(fcRat)); //计算后的税金
                var Acceptance_TotalTax = totalRent.toFixed(2) * 100;//计税总额            
                ZorPostSimpleData("/Base/AddAcceptance", JSON.stringify({ 'PropertyTax': PropertyTax, 'PersonalTax': PersonalTax, 'Acceptance_Tax': Acceptance_Tax, 'Acceptance_TotalTax': Acceptance_TotalTax, 'acceptance': JsData, 'startTime': bgDate, 'endTime': endDate }), function (data) {
                 
                    layer.msg(data.AnswerMeg, function () {
                        layer.closeAll();
                        Replace();
                    });;
                });
            }
       })
   })

    /**
   * 删除受理单信息
   */
    $(function () {
        $("#btnDelete").click(function () {
            var checkId = CheckboxValueIDs();
            if (checkId.length == 0) {
                layer.msg("请选择要删除的受理单信息！");                                                             //未选中任何行
                return;
            }
            else {
                layer.confirm("确定要删除吗?", { icon: 2, btn: ['确定', '取消'] }, function () {
                    ZorPostSimpleData("/Base/DeleteAcceptance", JSON.stringify({ 'id': checkId }), function (data) { //获取数据(带参数)
                        layer.msg(data.AnswerMeg, function () {
                            layer.closeAll();
                            Replace();
                        });
                    })
                })
            }
        })
    })

    /**
    * 查询楼宇
    */
    $(function () {
        $("#btnSearch").click(function () {
            ClearWebControls(divfrom);
            LayerOpen('650px', '400px', '受理单查询', $('#myModalSearch'));
        })
    })

    /**
    * 全选
    */
    $(function () {
        $("#cbkCheckAll").click(function () {
            if (this.checked) {
                $("input[name='chk']").prop('checked', true);
            } else {
                $("input[name='chk']").prop('checked', false);
            }
        })
    })

    function checkEndTime(startTime, endTime) {
        var start = new Date(startTime.replace("-", "/").replace("-", "/"));
        var end = new Date(endTime.replace("-", "/").replace("-", "/"));
        if (end < start) {
            return false;
        }
        return true;
    }
</script>

